home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Sources / FWIdle.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  4.2 KB  |  148 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWIdle.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWIDLE_H
  13. #include "FWIdle.h"
  14. #endif
  15.  
  16. #ifndef FWPART_H
  17. #include "FWPart.h"
  18. #endif
  19.  
  20. #ifndef FWFRAME_H
  21. #include "FWFrame.h"
  22. #endif
  23.  
  24. #ifndef FWPRIDEB_H
  25. #include "FWPriDeb.h"
  26. #endif
  27.  
  28. // ----- OpenDoc Includes -----
  29.  
  30. #ifndef SOM_ODSession_xh
  31. #include <ODSessn.xh>
  32. #endif
  33.  
  34. #ifndef SOM_ODDispatcher_xh
  35. #include <Disptch.xh>
  36. #endif
  37.  
  38. //========================================================================================
  39. // RunTime Info
  40. //========================================================================================
  41.  
  42. #if FW_LIB_EXPORT_PRAGMAS
  43. #pragma lib_export on
  44. #endif
  45.  
  46. #ifdef FW_BUILD_MAC
  47. #pragma segment fwpart2
  48. #endif
  49.  
  50. FW_DEFINE_CLASS_M0(FW_MIdle)
  51.  
  52. //========================================================================================
  53. // class FW_MIdle
  54. //========================================================================================
  55.  
  56. //----------------------------------------------------------------------------------------
  57. //    FW_MIdle::FW_MIdle
  58. //----------------------------------------------------------------------------------------
  59.  
  60. FW_MIdle::FW_MIdle(FW_CPart* part, FW_CFrame* frame) :
  61.     fPart(part),
  62.     fFrame(frame),
  63.     fRegistered(FALSE)
  64. {
  65.     FW_ASSERT(fPart != NULL);
  66. }
  67.  
  68. //----------------------------------------------------------------------------------------
  69. //    FW_MIdle::~FW_MIdle
  70. //----------------------------------------------------------------------------------------
  71.  
  72. FW_MIdle::~FW_MIdle()
  73. {
  74.     FW_ASSERT(fRegistered == FALSE);
  75. }
  76.  
  77. //----------------------------------------------------------------------------------------
  78. //    FW_MIdle::RegisterIdle
  79. //----------------------------------------------------------------------------------------
  80.  
  81. void FW_MIdle::RegisterIdle(Environment *ev, ODIdleFrequency frequency)
  82. {
  83.     if (fRegistered)
  84.     {
  85.         PrivSetIdleFrequency(ev, frequency);
  86.     }
  87.     else
  88.     {
  89.         PrivRegisterIdle(ev, frequency);    
  90.         fRegistered = TRUE;
  91.         fPart->PrivCountIdleRegistering(TRUE);
  92.     }
  93. }
  94.  
  95. //----------------------------------------------------------------------------------------
  96. //    FW_MIdle::UnregisterIdle
  97. //----------------------------------------------------------------------------------------
  98.  
  99. void FW_MIdle::UnregisterIdle(Environment *ev)
  100. {
  101.     if (fRegistered)
  102.     {
  103.         PrivUnregisterIdle(ev);
  104.         fRegistered = FALSE;
  105.         fPart->PrivCountIdleRegistering(FALSE);
  106.     }
  107. }
  108.  
  109. //----------------------------------------------------------------------------------------
  110. //    FW_MIdle::SetIdleFrequency
  111. //----------------------------------------------------------------------------------------
  112.  
  113. void FW_MIdle::SetIdleFrequency(Environment *ev, ODIdleFrequency frequency)
  114. {
  115.     if (fRegistered)
  116.         PrivSetIdleFrequency(ev, frequency);
  117.     else
  118.         RegisterIdle(ev, frequency);
  119. }
  120.  
  121. //----------------------------------------------------------------------------------------
  122. //    FW_MIdle::PrivRegisterIdle
  123. //----------------------------------------------------------------------------------------
  124.  
  125. void FW_MIdle::PrivRegisterIdle(Environment *ev, ODIdleFrequency frequency)
  126. {
  127.     fPart->GetSession(ev)->GetDispatcher(ev)->RegisterIdle(ev, fPart->GetODPart(ev), fFrame != NULL ? fFrame->GetODFrame(ev) : NULL, frequency);
  128. }
  129.  
  130. //----------------------------------------------------------------------------------------
  131. //    FW_MIdle::PrivUnregisterIdle
  132. //----------------------------------------------------------------------------------------
  133.  
  134. void FW_MIdle::PrivUnregisterIdle(Environment *ev)
  135. {
  136.     fPart->GetSession(ev)->GetDispatcher(ev)->UnregisterIdle(ev, fPart->GetODPart(ev), fFrame != NULL ? fFrame->GetODFrame(ev) : NULL);
  137. }
  138.  
  139. //----------------------------------------------------------------------------------------
  140. //    FW_MIdle::PrivSetIdleFrequency
  141. //----------------------------------------------------------------------------------------
  142.  
  143. void FW_MIdle::PrivSetIdleFrequency(Environment *ev, ODIdleFrequency frequency)
  144. {
  145.     fPart->GetSession(ev)->GetDispatcher(ev)->SetIdleFrequency(ev, fPart->GetODPart(ev), fFrame != NULL ? fFrame->GetODFrame(ev) : NULL, frequency);
  146. }
  147.  
  148.